<template>
	<view class="community">
		<view class="head_bg">
			<view class="cu-bar search">
				<view class="search-form bg-white" style="border-radius:50rpx;">
					<text class="cuIcon-search"></text>
					<input type="text" placeholder="" confirm-type="search" @input="getinputvalue"></input>
					 <view @tap="search" class="text-right margin-right-sm text-lg">搜索</view>
				</view>
			</view>
		</view>
		<view class="big_box" style="height: auto;">
			<view class="big_box_inner">
				<view class="big_inner_one" style="margin-bottom:20rpx;" v-for="(info,index) in list" :key="index">
					<view class="plot_inner" @tap="todetail(info)">
						<view class="plot_inner_left">{{info.residential_quarters_name}}</view>
						<view class="plot_inner_left">总成本：<text class="plot_inner_right">{{info.input_cost}}元</text><image class="plot_inner_img" src="../../../common/img/zhankai.png" mode=""></image></view>
					</view>
				</view>
				<view style="height:100rpx;"></view>
				<view v-if="list.length==0" class="margin-top-lg text-center">
					<image src='../../../common/img/no_data.png' style="width:275rpx;height:312rpx;"></image>
				</view>
				<view v-if="list.length>0" class="text-black text-df text-center bg-white padding-sm padding-left-lg be-gray">
					{{loadingTxt}} 共({{list.length}}条记录)
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	let page=1,timer=null
	export default {
		data() {
			return {
				list:[],
				total:0,
				name:'',
				loadingTxt:'加载更多',
				info:{
					residential_quarters_guid:'',//	字符串	小区标识
					residential_quarters_name:'',//		字符串	小区名称
					residential_quarters_address:'',//		字符串	小区地址
					input_cost:0.00,//		浮点型	总成本
				}
			}
		},
		onShow() {
			page=1;
			this.getInfo();
		},
		methods: {
			todetail(obj){
				uni.navigateTo({
					url: '../plotCost/plotCost??item='+JSON.stringify(obj)
				})
			},
			getinputvalue(e){
				this.name = e.detail.value;
				console.log(this.name);
			},
			search(){
				page=1;
				this.getInfo();
			},
			getInfo(){
				let that=this;
				that.http.tokenreq({
					url: 'costcontrol/v1/village',
					data: {
				    "pageindex":page,
					'village':this.name
					}
				}).then((res) => {
					let e=res.data;
					console.log(e);
					if(e.code==0 && e.success){
						this.list = e.rows;
						this.totle= e.total;
					}
				})
			},
			getmorelist(){
				this.loadingTxt='加载中'
				let that=this;
				that.http.tokenreq({
					url: 'costcontrol/v1/village',
					data: {
				    "pageindex":page,
					'village':this.name
					}
				}).then((res) => {
					console.log("res="+JSON.stringify(res));
					let e=res.data;
					if(e.code==0 && e.success){
						if(e.rows.length==0){
							that.loadingTxt="已经加载全部";
							return;
						}
						that.list=that.list.concat(e.rows);
						page++;
					}
				})
			},
			onReachBottom() {
				//阻止重复加载
				if(timer !== null){
					clearTimeout(timer)
				}
				timer=setTimeout(()=>this.getmorelist(),500)
				// this.getMoreNews()
			},
			
		}
	}
</script>
